/**
 * @project readnote
 * @Title ExpostulationDAOImpl.java
 * @author huxh
 * @date 2012-2-12
 **/
package com.readnote.expostulation.dao.impl;

import java.util.Collection;
import java.util.List;

import com.cr.backbone.hibenate.AppBaseDAOImpl;
import com.cr.backbone.hibenate.QueryParam;
import com.readnote.expostulation.dao.ExpostulationDAO;
import com.readnote.expostulation.model.Expostulation;
import com.readnote.user.model.User;

public class ExpostulationDAOImpl extends AppBaseDAOImpl<Expostulation> implements ExpostulationDAO{

	/**
	 * 获取最新发布的谏言，by 用户
	 * @methodDescribe
	 * @param user
	 * @return
	 * @author xianghua.hu
	 * @date 2012-3-6 下午05:18:39
	 */
	public Expostulation getExpostulationTopOneByCreateDateDesc(User user){
		Collection<Expostulation> cs =  getListExpostulationByUserOrderCreateDateDesc(user);
		if(cs!=null &&cs.size()>0)
			return (Expostulation) cs.toArray()[0];
		return null;
	}
	

	/**
	 * 根据用户获取检验，根据创建时间倒序
	 * @methodDescribe
	 * @param user
	 * @return
	 * @author xianghua.hu
	 * @date 2012-5-16 
	 */
	public Collection<Expostulation> getListExpostulationByUserOrderCreateDateDesc(
			User user){
		QueryParam param=new QueryParam();
		param.addQuery("eq_createUser.id_l", user.getId());
		param.addOrderDesc("createDate");
		Collection<Expostulation> list = getListByCriteria(param);
		return list;
	}
	
	
}
